#include "coordinate.h"
#include <iostream>
using namespace std;

void Coordinate::print(void) const
{
	cout << "(" << this->row << "," << this->col << ")";
}

ostream& operator<< (ostream& stream, const Coordinate& coo)
{
	stream << "(" << coo.row << "," << coo.col << ")";
	return stream;
}

relativeLocation Coordinate::whichSideIs(const Coordinate& coo) const
{
	relativeLocation rl;
	if (coo.row == this->row)
	{
		if (coo.col == this->col)
			rl = rlInside;
		else if (coo.col > this->col)
			rl = rlLeft;
		else if (coo.col < this->col)
			rl = rlRight;
	}
	else if (coo.row > this->row)
	{
		if (coo.col == this->col)
			rl = rlBottom;
		else if (coo.col > this->col)
			rl = rlBottomLeft;
		else if (coo.col < this->col)
			rl = rlBottomRight;
	}
	else if (coo.row < this->row)
	{
		if (coo.col == this->col)
			rl = rlTop;
		else if (coo.col > this->col)
			rl = rlTopLeft;
		else if (coo.col < this->col)
			rl = rlTopRight;
	}
	return rl;
}

Coordinate& Coordinate::operator= (const Coordinate& other)
{
	if (&other == this)
		return *this;
	this->col = other.col;
	this->row = other.row;
	return *this;
}